package iodemo;

import java.io.*;

public class ObjectIO
{
    public static void main (String[] args)
    {
//        try(ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("D:/TXTTTT")))
//        {
//            ObjectFile objectFile = new ObjectFile();
//
//            objectFile.setAge(21);
//            objectFile.setId("1098461579846144");
//            objectFile.setName("chen");
//
//            objectOutputStream.writeObject(objectFile);
//
//            objectOutputStream.flush();
//        }
//        catch(IOException e)
//        {
//            e.printStackTrace();
//        }
        
        try(ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream("D:/TXTTTT")))
        {
            ObjectFile objectFile = (ObjectFile) objectInputStream.readObject();
    
            System.out.println(objectFile);
        }
        catch(IOException | ClassNotFoundException e)
        {
            e.printStackTrace();
        }
    }
}
